package jvm.oom;

/**
 * vm args: -Xss128k
 */
public class JavaVMStackSOF {

    private int stackLength = 1;
    public void stackLeak(){
        stackLength++ ;
        stackLeak();
    }

    public static void main(String[] args) {
        JavaVMStackSOF stackSOF = new JavaVMStackSOF();

        try {
            stackSOF.stackLeak();
        } catch (Throwable throwable) {
            System.out.println(String.format("stack length:%s",stackSOF.stackLength));
            throw throwable;
        }

//        stack length:771
//        Exception in thread "main" java.lang.StackOverflowError
//        at jvm.oom.JavaVMStackSOF.stackLeak(JavaVMStackSOF.java:10)
//        at jvm.oom.JavaVMStackSOF.stackLeak(JavaVMStackSOF.java:11)
    }
}
